home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Video Toaster 4.3
/
Video Toaster v4.3.iso
/
3.1
/
toasterall
/
arexx_examples
/
lwm
/
pointcenter.lwm
< prev
next >
Wrap
Text File
|
1993-10-01
|
956b
|
56 lines
/* CMD: Point Center
* Find average point position, like center of mass
* By Arnie Cachelin © 1993 NewTek Inc.
*
*/
mxx="LWModelerARexx.port"
signal on error
signal on syntax
numeric digits 5
mxx_add = addlib(mxx,0)
call addlib("rexxmathlib.library",0,-30,0)
call main
if (mxx_add) then call remlib(mxx)
exit
syntax:
error:
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
if (mxx_add) then call remlib(mxx)
exit
main:
call sel_mode(USER)
c=xfrm_begin()
sx=0; sy=0; sz=0
do i=1 to c
v=xfrm_getpos(i)
sx=sx+word(v,1)
sy=sy+word(v,2)
sz=sz+word(v,3)
v=sx/c sy/c sz/c
end
call Notify(1,c" Points","!Point Center:",v)
return
Magnitude: PROCEDURE
arg v
return(sqrt(Dot(v,v)))
Dot: PROCEDURE
arg v1,v2
S=0
do i=1 to 3
S=S+word(v1,i)*word(v2,i)
end
return S
Dist: PROCEDURE
arg v1,v2
S=0
do i=1 to 3
S=S + (word(v2,i) - word(v1,i))^2
end
return sqrt(S)